<template>
  <div class="event-msg">
    <el-input v-model="eventMsgInput" type="textarea" :rows="21" placeholder="请输入短信内容" resize="none" />
    <el-button @click="sendEventMsg">发送短信</el-button>
  </div>
</template>

<script>
import { sendMessage } from '@/api/message'
import axios from 'axios'

export default {
  data() {
    return {
      sender: '',
      eventMsgInput: '葡萄美酒夜光杯，欲饮琵琶马上催。醉卧沙场君莫笑，古来征战几人回？',
      phoneSet: []
    }
  },
  created() {
    if (this.$route.query != null && this.$route.query.sender != null) { this.sender = this.$route.query.sender }
    if (this.$route.query != null && this.$route.query.eventMsgInput != null) { this.eventMsgInput = this.$route.query.eventMsgInput }
    if (this.$route.query != null && this.$route.query.phoneSet != null) { this.phoneSet = this.$route.query.phoneSet }
  },
  methods: {
    sendEventMsg() {
      // 发送事件短信
      // sendMessage({
      //     messageContent: this.eventMsgInput,
      //     sender: this.sender,
      //     phoneSet: this.phoneSet
      // }).then(({ data }) => {
      //     if (data.success) {
      //         this.$message({
      //             message: '发送成功',
      //             type: 'success'
      //         })
      //     } else {
      //         this.$message({
      //             message: '发送失败',
      //             type: 'error'
      //         })
      //     }
      // }).catch(() => {
      //     this.$message({
      //         message: '发送失败',
      //         type: 'error'
      //     })
      // })
      axios.post('https://183.6.107.239:6443/client/shorMsg/send', {
        messageContent: this.eventMsgInput,
        sender: this.sender,
        phoneSet: this.phoneSet
      }).then(({ data }) => {
        if (data.success) {
          this.$message({
            message: '发送成功',
            type: 'success'
          })
        } else {
          this.$message({
            message: '发送失败',
            type: 'error'
          })
        }
      }).catch(() => {
        this.$message({
          message: '发送失败',
          type: 'error'
        })
      })
    }
  }
}
</script>

<style scoped>
.event-msg {
    margin: 0 auto;
    width: 445px;
    height: 623px;
    background: rgba(47, 58, 77, 1);
    padding: 0 15px;

    .el-textarea {
        width: 100%;

        .el-textarea__inner {
            margin: 43px 0;
            padding: 15px;
            background: rgba(63, 79, 105, 1);
            border: none;
            border-radius: 4px;
            font-size: 14px;
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
            -ms-overflow-style: none;
            scrollbar-width: none;
        }

        .el-textarea__inner::-webkit-scrollbar {
            display: none;
        }
    }

    .el-button {
        width: 80px;
        height: 36px;
        display: block;
        margin: 0 auto;
        border-radius: 2px;
        background: rgba(80, 211, 225, 0.5);
        border: 1px solid rgba(90, 144, 153, 1);
        box-shadow: inset 0px 0px 4px rgba(80, 211, 225, 0.25);
        font-size: 16px;
        font-weight: 500;
        color: rgba(255, 255, 255, 1);
        padding: 0;
    }

}
</style>
